export function abbr(num, isByte, decimal = 2) {
	const abbrev = isByte ? ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] : ['K', 'M', 'B', 'T', 'Q'];
	const base = isByte ? 1024 : 1000;
	const sign = num < 0 ? -1 : 1;
	let number = Math.abs(num);
	if (isNaN(number)) return '-';
	if (number === 0) return '0';

	let scale = Math.floor(Math.log(number) / Math.log(base));
	scale = Math.min(scale, abbrev.length);


	number /= (base ** scale);

	const unit = abbrev[scale - 1] || '';
	return `${(number * sign).toFixed(decimal)}${unit}`;
}

export default {};
